package com.springclouddemo.service.user.controller;

import com.springclouddemo.common.Response;
import com.springclouddemo.service.system.client.feign.ISystemFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("api/v1/consumer/feignapi")
public class ConsumerFeignApiController {
    @Autowired
    private ISystemFeign client;

    @GetMapping("/hello/{name}")
    public String hello(@PathVariable("name") String name) {
        String response = client.hello(name);
        return response;
    }
    @GetMapping("/say/{name}")
    public Response<Map<String, Object>> say(@PathVariable("name") String name) {
        Response<Map<String, Object>> response = client.say(name);
        Map<String, Object> userinfo = new HashMap<>();
        userinfo.put("age", "100");
        userinfo.put("phone", "18181818181");
        response.getResult().putAll(userinfo);
        response.setMsg("获取信息成功!");
        return response;
    }
}
